﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web.Mvc;
using GWEB.WebBase.Data;
using GWEB.WebBase.Entity;
using GWEB.WebBase.Utility;
using GWEB.WebFrame.Public;
using Newtonsoft.Json;

namespace GWEB.WebFrame.Contract
{
    public class LinkListController : Controller
    {
        [ActionFilter(IsLogin = true)]
        public ActionResult Index(String Id,String KeyCode,String Cid)
        {
            
            
            ViewBag.Id = Id;
            ViewBag.KeyCode = KeyCode;
            ViewBag.Cid = Cid;
            return View(BasePage.V("Contract/LinkList"));            
        }
      
        [ActionFilter(IsLogin = true)]
        public JsonResult Data(String Id, String KeyCode)
        {
            DataRow drUser = BasePage.GetUser(Session);
            String leagueId = Fun.cString(drUser["LeagueId"].ToString());

            String sql = " select id, Cid, LinkName, KidsName, Sex from cu_Cus_contacts where Cid ={0} and IsKids = '1' and LeagueId = '{1}'";

        
            BasePage.bd.ColumnNameToLower = false;
            String str = JsonConvert.SerializeObject(BasePage.bd.ExecuteTable(string.Format(sql,Id, leagueId)));

            BasePage.bd.ColumnNameToLower = true;
            List<Dictionary<String, Object>> data = JsonConvert.DeserializeObject<List<Dictionary<String, Object>>>(str);
            return BasePage.Json(ResultData.OK(data));

        }
     

    }
}